<template>
	<view>
		<navBar title="电影详情" />
		<view class="header" :style="{'background-image': 'url(' + detail.poster + ')'}">
			<view class="content">
				<view class="">
					<img :src="detail.poster" alt=""
						style="height: 105px;width: 75px;margin-right: 6px;border-radius: 8px;">
				</view>
				<view class="movie-content">
					<view class="u-font-40 u-line-1 u-f-w" style="width: 400rpx;">{{detail.movieName}}</view>
					<view class="u-font-26">
						<text class="score">
							<text>电影评分</text>
							<text class="rated-score">{{detail.grade||'暂无'}}</text>
						</text>
					</view>
					<view class="u-font-26">导演：{{detail.director || '暂无'}}</view>
					<view class="u-font-26 u-line-1" style="width: 400rpx;">主演：{{detail.cast || ''}}</view>
				</view>
			</view>
			<view class="task"></view>
		</view>
		<view class="u-p-t-30">
			<u-tabs :list="list" active-color="#FF6801" :is-scroll="false" :current="current" @change="change"></u-tabs>
		</view>
		<view class="u-p-t-20">
			<view v-if="current==0">
				<view class=" u-p-l-30 u-p-r-30" :class="[readMore?'u-line-4':'']">{{detail.summary}}</view>
				<view @click="toggle"> 
					<view class="detaileMore u-type-info-dark u-flex u-row-center" style="height: -1rpx;" v-if="readMore">
						<text class="u-p-r-10 u-type-warning-dark">展开阅读更多</text>
						<u-icon name="arrow-down" :color="$u.color.warningDark"></u-icon>
					</view>
					<view class="u-flex u-type-info-dark u-row-center u-p-t-20" v-else>
						<text class="u-p-r-10 u-type-warning-dark">收起</text>
						<u-icon name="arrow-up" :color="$u.color.warningDark"></u-icon>
					</view>
				</view>
				
			</view>
			<view v-if="current==1">
				<view class="u-flex-col u-row-center u-col-center">
					<u-icon name="photo" size="80" :color="$u.color.info"></u-icon>
					<view class="u-type-info u-p-t-10">暂无数据</view>
				</view>
			</view>
			<view v-if="current==2">
				<view class="u-flex-col u-row-center u-col-center">
					<u-icon name="photo" size="80" :color="$u.color.info"></u-icon>
					<view class="u-type-info u-p-t-10">暂无数据</view>
				</view>
			</view>
		</view>
		<view class="u-p-l-30 u-p-r-30 u-p-t-30 u-m-t-30">
			<view class="u-p-10 u-flex u-row-center u-type-info" style="border: 1px dashed #ccc;" @click="chooseCity">
				<text class="u-p-r-10">全城筛选</text>
				<u-icon name="arrow-down"></u-icon>
			</view>
		</view>
		<!-- 影院列表 -->
		<view class="u-p-b-15">
			<cinemaList ref="cinemaList" :page="page" />
		</view>
		
		<u-picker mode="selector" v-model="cityChooseShow"  :default-selector="[1]" :range="actions" range-key="name" :confirm-color="$u.color.warningDark" @confirm="confirm"></u-picker>
	</view>
</template>


<script>
	import navBar from '@/components/navbar/index'
	import cinemaList from './components/cinemaList.vue'
	export default {
		data() {
			return {
				cinemaParams: {
					cityId: '',
					lat: '', // 经度
					lng: '', //纬度
					movieAreaId: '',
					movieId: '',
					page: 1,
					size: 10
				},
				detail: {},
				current: 0,
				list: [{
					name: '简介'
				}, {
					name: '演员'
				}, {
					name: '剧照'
				}],
				readMore:true,
				page: 1,
				cityChooseShow:false,
				actions:[]
			}
		},
		components: {
			navBar,
			cinemaList
		},
		onPullDownRefresh() {
			this.cinemaParams.lat = localStorage.getItem('lat')
			this.cinemaParams.lng = localStorage.getItem('lng')
			this.cinemaParams.cityId = localStorage.getItem('cityId')
			this.cinemaParams.movieId = this.$route.query.movieId;
			this.getRegionList();
			this.getFilmInfo();
			this.$refs.cinemaList.page = 1;
			this.$refs.cinemaList.cinemaList = [];
			this.$refs.cinemaList.getCinemaList();
		},
		onReachBottom() {
			this.$refs.cinemaList.page = ++this.$refs.cinemaList.page;
			this.$refs.cinemaList.getCinemaList();
		}, 
		mounted() {
			this.cinemaParams.lat = localStorage.getItem('lat')
			this.cinemaParams.lng = localStorage.getItem('lng')
			this.cinemaParams.cityId = localStorage.getItem('cityId')
			this.cinemaParams.movieId = this.$route.query.movieId;
			this.getRegionList();
			this.getFilmInfo();
			this.$refs.cinemaList.getCinemaList();
		},
		methods: {
			getFilmInfo() {
				this.$u.api.getFilmInfo({
					id: this.cinemaParams.movieId
				}).then(res => {
					if (res.code == 0) {
						this.detail = res.data;
					}
				})
			},
			change(val) {
				this.current = val;
			},
			toggle(){
				this.readMore = !this.readMore
			},
			chooseCity(){
				this.cityChooseShow = true;
			},
			getRegionList(){
				this.$u.api.regionList({cityId: this.cinemaParams.cityId}).then(res=>{
					if (res.code == 0) {
						let data = res.data || []
						this.actions = data.map(item => {
							item.name = item.areaName
							return item
						})
					}
				})
			},
			confirm(val){
				this.$refs.cinemaList.cinemaFrom.movieAreaId= this.actions[val[0]].id;
				this.$refs.cinemaList.page = 1;
				this.$refs.cinemaList.cinemaList = [];
				this.$refs.cinemaList.getCinemaList();
			}
		}
	}
</script>

<style scoped>
	.header {
		background-size: cover;
		background-position: center;
		background-repeat: no-repeat;
		width: 100%;
		height: 600rpx;
		position: relative;
	}

	.task {
		z-index: 1000;
		position: absolute;
		top: 0;
		bottom: 0;
		right: 0;
		left: 0;
		background: linear-gradient(to bottom, rgba(187, 115, 115, 0.1), rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 1));
	}

	.content {
		z-index: 1001;
		position: absolute;
		bottom: 0;
		padding: 0 30rpx;
		display: flex;
		height: 210rpx;
	}

	.line-ellipsis {
		text-overflow: ellipsis;
		overflow: hidden;
		white-space: nowrap;
	}

	.rated-score {
		color: #FF6600;
		font-size: 32rpx;
	}

	.jianjie {
		padding: 0 30rpx 30rpx;
	}

	.jianjie .title {
		font-size: 32rpx;
		color: #333333;
		margin-bottom: 10rpx;
	}

	.jianjie .detaile {
		font-size: 24rpx;
		color: #999999;
	}

	.line-clamp {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 3;
		text-overflow: ellipsis;
		word-wrap: break-word;
		word-break: break-all;
		overflow: hidden;
	}

	.viewAll {
		display: flex;
		color: #FF6600;
		font-size: 26rpx;
		align-items: center;
		justify-content: center;
	}

	.shuaixuan {
		font-size: 26rpx;
		height: 70rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #999999;
		border: 2rpx dashed #ECEAEA;
		margin-top: 30rpx;
	}

	.marginTop {
		margin-top: 20rpx;
	}

	.title {
		font-size: 32rpx;
	}

	.location-block {
		display: flex;
		font-size: 26rpx;
		justify-content: space-between;
		margin: 8rpx 0 12rpx 0;
		color: #777;
	}

	.moiveTag {
		background-image: linear-gradient(to right, #FF6600, #FF9933);
		margin-right: 10rpx;
	}

	.card {
		border-radius: 5px;
		box-shadow: 0 4rpx 24rpx 0 rgb(0 0 0 / 10%);
		padding: 20rpx 0;
	}

	.navbar {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		z-index: 1002;
		height: 92rpx;
		font-size: 32rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.yanse {
		background-image: linear-gradient(to right, #FF6600, #FF9933);
	}

	.navbar .van-icon {
		color: #ffffff;
		background-color: rgb(0, 0, 0, 0.3);
		border-radius: 50%;
		padding: 8rpx;
		position: absolute;
		left: 30rpx;
	}

	.navbar .title {
		color: white;
	}

	.actor-img {
		position: relative;
		margin-top: 20rpx;
		width: 170rpx;
		height: 230rpx;
		border-radius: 10rpx;
		overflow: hidden;
	}

	.actor-name {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		text-align: center;
		color: #ffffff;
		line-height: 40rpx;
		font-size: 24rpx;
		background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), #000);
		opacity: 0.5;
	}

	.move-img {
		margin-top: 20rpx;
		width: 318rpx;
		height: 230rpx;
		border-radius: 10rpx;
		overflow: hidden;
	}


	.distance {
		padding-left: 30rpx;
		padding-top: 4rpx;
	}

	.movie-content {
		height: 210rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.none-tip {
		color: #969799;
		font-size: 28rpx;
		line-height: 100rpx;
		text-align: center;
	}
	.detaileMore{
		position: relative;
		background-image: linear-gradient(-180deg, rgba(255, 255, 255, 0) 0%, rgb(255, 255, 255) 80%);
		margin-top: -160rpx;
		padding-top: 160rpx;
	}
</style>
